This data came from RNOAA, an R package published by the National Oceanic and Atmospheric Administration (NOAA). It contains temperaturee and precipitation information for three locations in the U.S., with one measurement for each month of 2021 and 2022. Click on the dashboard linked below to visualize some interesting patterns in the dataset.
The dashboard will open in a new tab.
The following code chunks demonstrate how I created the plots that are shown in the Dashboard.
The code chunk below shows how the data was imported from the RNOAA package and edited to meet my needs for the purposes of this dashboard.
# Import Data
weather_df =
rnoaa::meteo_pull_monitors(
c("USW00094728", "USW00022534", "USS0023B17S"),
var = c("PRCP", "TMIN", "TMAX"),
date_min = "2021-01-01",
date_max = "2022-12-31") |>
mutate(
name = case_match(
id,
"USW00094728" ~ "CentralPark_NY",
"USW00022534" ~ "Molokai_HI",
"USS0023B17S" ~ "Waterhole_WA"),
tmin = tmin / 10,
tmax = tmax / 10,
month = lubridate::floor_date(date, unit = "month")) |>
select(name, id, everything())
# Alter Dataframe
weather_df = weather_df |>
drop_na() |>
mutate(
tavg = (tmax + tmin) / 2,
name_str = str_replace_all(name, c("CentralPark" = "Central Park", "_" = ", "))
)
The chart below shows average daily temperatures for the three locations documented in the RNOAA weather dataset: Central Park, NY; Molokai, HI; and Waterhole, WA
weather_df |>
plot_ly(x = ~month, y = ~tavg, color = ~name_str,
type = "scatter", mode = "markers") |>
layout(
title = "Average Daily Temperatures over Time",
xaxis = list(title ="Date"),
yaxis = list(title = "Average Daily Temperature (°C)")
)
The chart below shows the temperature distribution for each month in 2022. The boxplots below contain data from all three locations in the dataset.
weather_df |>
filter(year(month) == 2022) |>
mutate(
month_name = as.factor(substr(month.name[month(month)], 1, 3)),
month_name = fct_reorder(month_name, month(month))
) |>
plot_ly(x = ~month_name, y = ~tavg, color = ~month_name,
type = "box", colors = "viridis") |>
layout(
title = "Temperature Distrubution for each Month in 2022",
xaxis = list(title ="Month"),
yaxis = list(title = "Average Daily Temperature (°C)")
)
The last chart shows the ten “rainiest” (or more accurately, highest precipitation) dates in Waterhole, WA. I’m from Washington, so I chose the location from my very lovely and very rainy home state.
weather_df |>
drop_na() |>
filter(name == "Waterhole_WA", !(date %in% c(as.Date("2022-04-05"), as.Date("2022-12-26")))) |>
mutate(date = fct_reorder(as.factor(date), prcp)) |>
arrange(-prcp) |>
head(10) |>
plot_ly(x = ~date, y = ~prcp, type = "bar", color = ~name_str) |>
layout(
title = "The 10 Rainiest Days in Waterhole, WA",
xaxis = list(title ="Date"),
yaxis = list(title = "Precipitation (cm)")
)